package com.chj.resources;

import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api")
public class TestResource02 {

	@GetMapping("/test")
	public String test() {
		return "test --> ";
	}

	// @PreAuthorize("hasRole('select')")
	@GetMapping("/test1")
	public String test1(@RequestParam("p") String param) {
		String loginUser = (String) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
		return param + " --> " + "TestResource02.test1 --> " + loginUser;
	}

	// @PreAuthorize("hasRole('update')")
	@GetMapping("/test2")
	public String test2(@RequestParam("p") String param) {
		String loginUser = (String) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
		return param + " --> " + "TestResource02.test2 --> " + loginUser;
	}
}
